package com.easyedu.core.dao;

import com.easyedu.core.entity.po.OpenCourseTimeVersion;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author mengranliu
 * @date 2022/3/30
 * @describe
 */
@Mapper
public interface OpenCourseTimeVersionDao {


     /**
      * 获取通过版本uuid获取版本信息
      * @param versionId
      * @return 版本信息
      */
     @Select("select * from open_course_time_version where open_course_time_mid_version_id = #{versionId} ")
     OpenCourseTimeVersion getByVersionId(String versionId);

     @Select("select * from open_course_time_version where open_year = #{openYear} and  "
             + " semester = #{semester} and open_course_time_mid_version_id = #{versionId}")
     OpenCourseTimeVersion getByOpenYearAndVersionId(int openYear, String semester, String versionId);

     @Select("select * from open_course_time_version where open_year = #{openYear} "
             + "and semester = #{semester} and  open_course_time_mid_version_name = " + "#{versionName}")
     OpenCourseTimeVersion getByName(int openYear, String semester, String versionName);

     /**
      * 增加一个新的排课版本
      *
      * @param openYear    开课年
      * @param semester    开课学期
      * @param versionUUID 版本唯一id
      * @param versionName 版本名
      * @param classRoomPrice
      * @return 插入数据库的数量
      */
     @Insert("insert into open_course_time_version(open_year, semester, open_course_time_mid_version_id,"
             + "open_course_time_mid_version_name,classroom_price) VALUE (#{openYear},#{semester},#{versionUUID},"
             + "#{versionName},#{classRoomPrice})")
     Integer addNewVersion(int openYear, String semester, String versionUUID, String versionName, float classRoomPrice);

     @Select("select * from open_course_time_version")
     List<OpenCourseTimeVersion> getAll();

     /**
      * 根据年份和学期获取版本列表
      * @param openYear 开课年份
      * @param semester 开课学期
      * @return 版本列表
      */
     @Select("select * from open_course_time_version where open_year = #{openYear} and semester = #{semester}")
     List<OpenCourseTimeVersion> getByOpenYearAndSemester(int openYear, String semester);


}
